#pragma once

namespace singleton {

    template<typename T>
    class Singleton {

    public:

        static T *getInstance() {
            if (instance_ == nullptr) {
                instance_ = new T();
            }
            return instance_;
        }

    private:

        Singleton() = default;

        Singleton(const Singleton<T> &) = default;

        ~Singleton() = default;

        Singleton<T> &operator=(const Singleton<T> &) = default;

    private:

        static T *instance_;

    };

    template<typename T>
    T *Singleton<T>::instance_ = nullptr;

}